﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<!--头部-->
<header class="publicHeader">
    <h1>超市账单管理系统</h1>
    <div class="publicHeaderR">
        <p><span id="hours">下午好！</span><span style="color: #fff21b"> Admin</span> , 欢迎你！</p>
        <a href="/logout">退出</a>
    </div>
</header>
<!--时间-->
<section class="publicTime">
    <span id="time">2015年1月1日 11:11  星期一</span>
    <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器！（IE10+）</a>
</section>
<!--主体内容-->
<section class="publicMian ">
    <div class="left">
        <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
        <nav>
            <ul class="list">
                <li id="active"><a href="billList">账单管理</a></li>
                <li><a href="providerList">供应商管理</a></li>
                <li><a href="userList">用户管理</a></li>
                <li><a href="password">密码修改</a></li>
                <li><a href="uploadPage">文件上传</a></li>
                <li><a href="/toDownload">文件下载</a></li>
                <li><a href="login">退出系统</a></li>
            </ul>
        </nav>
    </div>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>账单管理页面</span>
        </div>
        <form action="billListPage">
            <div class="search">
                <span>商品名称：</span>
                <input type="text" placeholder="请输入商品的名称" name="tradeName" th:value="${where.tradeName}"/>

                <span>供应商：</span>
                <!--                <input type="text" placeholder="供应商" name="supplierID" th:value="${where.supplierID}"/>-->

                <select name="supplierID" id="supplier" style="width: 200px">
                    <option value="">--请选择相应的提供商--</option>

                </select>

                <span>是否付款：</span>
                <select name="pay">
                    <option value="" th:selected="${where.pay==null}">--请选择--</option>
                    <option value=1 th:selected="${where.pay==true}">已付款</option>
                    <option value=0 th:selected="${where.pay==false}">未付款</option>
                </select>

                <input type="submit" value="查询" style="width: 100px;background:darkseagreen"/>

        </form>
        <div th:if="${session.loginUser.permission==1}">
            <a href="billAddPage">添加订单</a>
        </div>

    </div>
    <!--账单表格 样式和供应商公用-->
    <table class="providerTable" cellpadding="0" cellspacing="0">
        <tr class="firstTr">
            <th width="10%">账单编码</th>
            <th width="20%">商品名称</th>
            <th width="10%">供应商</th>
            <th width="10%">账单金额</th>
            <th width="10%">是否付款</th>
            <th width="10%">创建时间</th>
            <th width="30%">操作</th>
        </tr>
        <tr th:each="bill:${bills}">
            <td th:text="${bill.orderCode}">213</td>
            <td th:text="${bill.tradeName}">213</td>
            <td th:text="${bill.supplier_.supplierName}">213</td>
            <td th:text="${bill.totalAmount}">213</td>

            <td th:if="${bill.pay}">已付款</td>
            <td th:unless="${bill.pay}">未付款</td>
            <td th:text="${#dates.format(bill.createTime,'yyyy年MM月dd日 HH:mm')}"></td>
            <td>
                <!--                向后台传递id参数-->
                <a th:href="@{'billViewPage?orderCode='+${bill.orderCode}}"><img src="img/read.png" alt="查看"
                                                                                 title="查看"/></a>

                <a th:if="${session.loginUser.permission==1}"
                   th:href="@{'billUpdateForSelect?orderCode='+${bill.orderCode}}"><img src="img/xiugai.png"
                                                                                        alt="修改"
                                                                                        title="修改"/></a>


                <a th:if="${session.loginUser.permission==1}" th:href="@{'billDeleteById?orderCode='+${bill.orderCode}}"
                   class="removeBill"><img
                        src="img/schu.png"
                        alt="删除"
                        title="删除"/></a>

            </td>
        </tr>

    </table>
    </div>
</section>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeBi">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该订单吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>

<footer class="footer">
</footer>

<script src="js/jquery.js"></script>
<script src="js/js.js"></script>
<script src="js/time.js"></script>
<script th:inline="JavaScript" type="text/javascript">

    //th:inline="JavaScript" 脚本里可以调用 th里面的属性

    var supplierId = [[${where.supplierID}]]
    console.log(supplierId)
    //页面一旦启动就会自动调用
    $.ajax({
        url: "http://localhost/getSuppliers",
        type: "get",
        data: null,
        success: function (d) {
            console.log(d)
            for (var i = 0; i < d.length; i++) {
                if (supplierId == d[i].supplierId)
                    $("#supplier").append("<option value=" + d[i].supplierId + " selected>" + d[i].supplierName + "</option>")
                else
                    $("#supplier").append("<option value=" + d[i].supplierId + ">" + d[i].supplierName + "</option>")
            }
        }
    })


</script>

</body>
</html>
